'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE } = app.Sequelize;

  const UserResumeExperience = app.model.define('user_resume_experience', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    user_id: {
      type: INTEGER,
      allowNull: false,
    },
    resume_id: {
      type: INTEGER,
      allowNull: false,
      references: {
        model: 'user_resumes',
        key: 'id'
      }
    },
    position: {
      type: STRING(255),
      comment: '职位'
    },
    company_name: {
      type: STRING(255),
      comment: '公司名称'
    },
    work_start_time: DATE,
    work_end_time: DATE,
    remark: {
      type: STRING(255),
      comment: '工作内容'
    },
    created_at: DATE,
    updated_at: DATE,
  }, {
    timestamps: true,
    tableName: 'user_resume_experience',
  });
  UserResumeExperience.associate = function() {
    app.model.UserResumeExperience.belongsTo(app.model.UserResumes, { foreignKey: 'resume_id' });
  };
  return UserResumeExperience;
};
